package cn.chair.dao;

import cn.chair.entity.User;
import cn.chair.entity.UserWeb;
import cn.chair.model.admin.UserWebResp;
import life.innovation.dao.EntityDaoImpl;
import life.innovation.exception.DataReadException;
import life.innovation.model.PageList;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;

@Repository
public class UserWebDao extends EntityDaoImpl<UserWeb> {

    public UserWebDao(DataSource dataSource) {
        super(dataSource, UserWeb.class);
    }

    public PageList<UserWebResp.UserList> getUser(Integer userId,String mobile,int page,int countPerPage) throws DataReadException {

        Map<String,Object> params = new HashMap<>();
        mobile = (mobile==null||mobile.trim().isEmpty())?null:mobile.trim();

        params.put("userId",userId);
        params.put("mobile",mobile);

        return findPage("db/sql/user/getUserWeb.sql",UserWebResp.UserList.class,page,countPerPage,params);

    }
}
